<template>
  <el-form ref="form" class="form" label-width="80px">
    <!-- <h5>立即注册</h5> -->
    <router-link tag="h5" to="/userlogin/register">立即注册</router-link>
    <p>
      账号
      <el-input v-model="userName" placeholder="请输入账号"></el-input>
    </p>
    <p>
      密码
      <el-input
        placeholder="请输入密码"
        v-model="password"
        show-password
      ></el-input>
    </p>
    <!-- <h5>忘记密码？</h5> -->
    <router-link tag="h5" to="/userlogin/chgpassword">忘记密码</router-link>
    <el-button type="primary" @click="loginEvt">登录</el-button>
  </el-form>
</template>

<script>
import { userLogin } from "../../api/login";

export default {
  data() {
    return {
      password: "",
      userName: "",
    };
  },
  methods: {
    loginEvt() {
      userLogin(this.userName,this.password).then(res=>{
        if( res.ok === 1){
          sessionStorage.setItem('token',res.token)
          this.$router.push('/home')
        }
      })
    
    },
  },
};
</script>

<style lang='scss' scoped>
.form {
  width: 420px;
  height: 350px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  text-align: center;
}
.el-input {
  width: 90%;
  margin-top: 14px;
}
h5 {
  text-align: right;
  margin-right: 8px;
}
</style>